/**   
 * @Title: ConListAdapter.java 
 * @Package com.cdtv.home.adapter 
 * @Description: 
 * @author zhuw
 * @date 2012-7-18 下午3:27:20 
 */
package com.adpter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.ocean.util.common.StringUtil;
import com.common.method.ServerPath;
import com.matang.R;
import com.modle.User;
import com.util.OUtil;

/**
 * 
 * @ClassName:IyrUserListAdapter
 * @Description:TODO
 * @author zhuw
 * @date 2013-7-24 上午11:29:54
 */
public class IyrUserListAdapter extends CusBaseAdapter {
	private List<User> list;
	private Context context;

	/**
	 * @param list
	 * @param context
	 */
	public IyrUserListAdapter(List<User> list, Context context) {
		super();
		
		this.list = list;
		this.context = context;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		ViewHolder vh = null;
		if (view == null) {
			view = LayoutInflater.from(context).inflate(R.layout.list_item_iyr,
					null);
			vh = new ViewHolder();
			vh.nickNameTv = (TextView) view.findViewById(R.id.nick_name_tv);
			vh.timeTv = (TextView) view.findViewById(R.id.time_tv);
			vh.qmTv = (TextView) view.findViewById(R.id.qm_tv);
			vh.thumbIv = (ImageView) view.findViewById(R.id.thumb_iv);
			vh.bgIv = (ImageView) view.findViewById(R.id.bg_iv);
			view.setTag(vh);
		} else {
			vh = (ViewHolder) view.getTag();

		}
		User user = list.get(position);
		if (StringUtil.isNull(user.name)) {

			vh.nickNameTv.setText(StringUtil.mobileEncry(user.mobile));
		} else {

			vh.nickNameTv.setText(user.name);
		}
		vh.qmTv.setText(user.signature);
		imageLoader.bind(vh.thumbIv, ServerPath.SERVER
				+ list.get(position).thumb, null, R.drawable.default_head);
		OUtil.setThumbBg(user, vh.bgIv);
		return view;
	}

	class ViewHolder {
		TextView nickNameTv, timeTv, qmTv;
		ImageView thumbIv, bgIv;

	}

}
